package com.example.system.serviceImpl;

import com.example.system.dao.UserDAO;
import com.example.system.entity.User;
import com.example.system.service.SystemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("SystemServiceImpl")
public class SystemServiceImpl implements SystemService {

    @Autowired
    UserDAO userDAO;

    @Override
    public User queryUser(User user) {
        User u = userDAO.queryUser(user);
        return u;
    }

    @Override
    @Transactional
    public void saveUser(User user) {
        userDAO.saveUser(user);
    }

    @Override
    public PageInfo<User> queryInfo(User user, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userDAO.queryInfo(user);
        PageInfo<User> dataList  =  new PageInfo<User>(list);
        return dataList;
    }
}
